#include<bits/stdc++.h>
using namespace std;
int T,n,m,L,V,maxn=INT_MIN;
long long vx,VV;
bool f;
int d[100010],v[100010],a[100010],p[100010];
inline int read()
{
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)&&c!='-') c=getchar();
    if(c=='-')
    {
        f=-1;
        c=getchar();
    }
    while(isdigit(c))
    {
        x=x*10+c-'0';
        c=getchar();
    }
    return x*f;
}
inline void write(long long x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    T=read();
    while(T--)
    {
        int ans1=0;
        n=read();m=read();L=read();V=read();
        VV=V*V;
        d[1]=read();v[1]=read();a[1]=read();
        if(a[1]!=0) f=1;
        for(int i=2;i<=n;i++)
        {
            d[i]=read();v[i]=read();a[i]=read();
        }
        for(int i=1;i<=m;i++) p[i]=read();
		for(int i=1;i<=n;i++)
        {
            if(f&&p[m]>=d[i])
            {
                vx=v[i]*v[i]+2*a[i]*(p[m]-d[i]);
                if(vx>VV) ans1++;
            }
            else if(v[i]>V&&d[i]<=p[m]) ans1++;
        }
        write(ans1);putchar(' ');
        if(ans1==0) write(m);
        else write(m-1);
        putchar('\n');
    }
    return 0;
}
